 <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('【数据】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>IMEI编号：</label>-->
<!--                                <input type="text" name="imeiId"/>-->
<!--                            </li>-->
                            <li>
                                <label>账号：</label>
                                <input type="text" name="account"/>
                            </li>

<!--                            <li>-->
<!--                                <label>HEM总数：</label>-->
<!--                                <input type="text" name="hme"/>-->
<!--                            </li>-->
                            <li>
                                <label>军团名称：</label>
                                <input type="text" name="corporationName"/>
                            </li>
                            <li>
                                <label>游戏名：</label>
                                <input type="text" name="gameName"/>
                            </li>
<!--                            <li>-->
<!--                                <label>等级：</label>-->
<!--                                <input type="text" name="grade"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>排名：</label>-->
<!--                                <input type="text" name="ranking"/>-->
<!--                            </li>-->
                            <li>
                                <label>段位：</label>
                                <input type="text" name="danGrading"/>
                            </li>
<!--                            <li>-->
<!--                                <label>胜率：</label>-->
<!--                                <input type="text" name="winRate"/>-->
<!--                            </li>-->
                            <li>
                                <label>账号状态：</label>
                                <select  name="accountStatus">
                                    <option value="">请账号状态</option>
                                        <option value="没加军团" id="id1">没加军团</option>
                                        <option value="战舰不够" id="id2">战舰不够</option>
                                        <option value="匹配失败" id="id3">匹配失败</option>
                                        <option value="账号密码错误" id="id4">账号密码错误</option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>账号状态：</label>-->
<!--                                <input type="text" name="accountStatus"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>关卡：</label>-->
<!--                                <input type="text" name="checkpoint"/>-->
<!--                            </li>-->
                            <li>
                                <label>分组：</label>
                                <select  name="groupId">
                                    <option value="">请选择分组</option>
                                    <option th:each=" group : ${groupings}"  th:text="${group.name}" th:value="${group.id}"></option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>分组：</label>-->
<!--                                <input type="text" name="groupId"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>登录的用户名称：</label>-->
<!--                                <input type="text" name="userName"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                shiro:hasPermission="system:list:add"-->
                <a class="btn btn-success" onclick="$.operate.add()" >
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:list:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:list:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
<!--                shiro:hasPermission="system:list:export"-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" >-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
                <a class="btn btn-info" onclick="$.table.importExcel()" th:if="${loginUser} eq admin">
                    <i class="fa fa-upload"></i> 导入
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        // [[${@permission.hasPermi('system:list:edit')}]]
        // [[${@permission.hasPermi('system:list:remove')}]]
        var editFlag = null;
        var removeFlag = null;
        var prefix = ctx + "system/list";

        $(function() {
            loginUser=[[${loginUser}]];
            // console.log(loginUser)
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "【数据列表】",
                columns: [
                    {
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                // {
                //     field: 'imeiId',
                //     title: 'IMEI编号'
                // },
                {
                    field: 'account',
                    title: '账号'
                },

                {
                    field: 'password',
                    title: '密码'
                },
                    {
                        field: 'name',
                        title: '分组'
                    },
                    {
                        field: 'againstType',
                        title: '对战类型'
                    },
                {
                    field: 'accountStatus',
                    title: '账号状态'
                },
                {
                    field: 'hme',
                    title: 'HEM总数'
                },
                {
                    field: 'corporationName',
                    title: '军团名称'
                },
                {
                    field: 'gameName',
                    title: '游戏名'
                },
                {
                    field: 'grade',
                    title: '等级',
                    sortable: true
                },
                {
                    field: 'ranking',
                    title: '排名',
                    sortable: true
                },
                {
                    field: 'danGrading',
                    title: '段位',
                    sortable: true
                },
                {
                    field: 'winRate',
                    title: '胜率',
                    sortable: true
                },
                {
                    field: 'checkpoint',
                    title: '关卡'
                },
                // {
                //     field: 'groupId',
                //     title: '分组'
                // },
                // {
                //     field: 'userName',
                //     title: '登录的用户名称'
                // },
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"  onclick="$.operate.edit(\'' + row.id + '\')" ><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
                ]
            }

            if(loginUser=="admin"){
                options.columns.push(
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" th:if="loginUser == "user"" onclick="$.operate.edit(\'' + row.id + '\')" ><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                )
            }


            if(loginUser!= "admin"){
                options.columns.push(
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')" ><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                )
            }
            $.table.init(options);
        });
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>